﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp8
{

    class Cq : Father
    {
        public Cq(string name, string playname) : base(name, playname) 
        { 
        
        }
        public Cq() 
        { }
        public override void hello()
        {
            Console.WriteLine($"{this.name}");
        }
        public void gogame()
        {
            int platname1 = 0;//
            int botname1 = 0;
            int pj = 0;
            Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>");
            string name =Console.ReadLine();//
            if (name.Equals("1"))
            {
                Cq cq = new Cq("刘备","");
                cq.hello();
                name = "刘备";
            }
            else if (name.Equals("2"))
            {
                Cq cq1 = new Cq("孙权", "");
                cq1.hello();
                name = "孙权";
            }
            else if (name.Equals("3"))
            {
                Cq cq2 = new Cq("曹操", "");
                cq2.hello();
                name = "曹操";

            }
            Console.WriteLine("请输入您的姓名");
            string playname = Console.ReadLine();
            Console.WriteLine($"{playname}  VS  {name}");
            Console.WriteLine("开始游戏吗？《y/n》");
            string game = Console.ReadLine();
            if (game.Equals("y"))
            {
                Console.WriteLine("请出拳：1.石头，2.剪刀，3.布（输入相应的数字）");
                int i = int.Parse(Console.ReadLine());
                if (i==1)
                {
                    Console.WriteLine($"{playname} ：出拳  {sjb.石头}");
                    Random random = new Random();
                    int a = random.Next(1, 4);
                    switch (a)
                    {
                        case 1:
                            Console.WriteLine( $"{name}  出拳  {sjb.石头}" );
                            break;
                        case 2:
                            Console.WriteLine($"{name}  出拳  {sjb.剪刀}");
                            break;
                        case 3:
                            Console.WriteLine($"{name}  出拳  {sjb.布}");
                            break;
                        default:
                            break;
                    }
                    if (a==3)
                    {
                        Console.WriteLine($"笨蛋 {playname}你输了");
                        botname1++;
                    }
                    if (a==2)
                    {
                        Console.WriteLine($"不错 {playname} 你赢了");
                        pj++;
                    }
                    if (a==1)
                    {
                        Console.WriteLine("平局 走着瞧");
                        platname1++;
                    }
                }
                if (i==2)
                {
                    Console.WriteLine($"{playname}  出拳  {sjb.剪刀}");
                    Random random = new Random();
                    int a = random.Next(1, 4);
                    switch (a)
                    {
                        case 1:
                            Console.WriteLine($"{name}  出拳  {sjb.石头}");
                            break;
                        case 2:
                            Console.WriteLine($"{name}  出拳  {sjb.剪刀}");
                            break;
                        case 3:
                            Console.WriteLine($"{name}  出拳  {sjb.布}");
                            break;
                        default:
                            break;
                    }
                    if (a==1)
                    {
                        Console.WriteLine($"笨蛋 {playname} 你输了");
                        botname1++;
                    }
                    else if (a==2)
                    {
                        Console.WriteLine("平局 ");
                        pj++;
                    }
                    else
                    {
                        Console.WriteLine($"不错 {playname} 你赢了");
                    }
                }
                if (i==3)
                {
                    Console.WriteLine($"{playname}  出拳  {sjb.布}");
                    Random random = new Random();
                    int a = random.Next(1, 4);
                    switch (a)
                    {
                        case 1:
                            Console.WriteLine($"{name} 出拳  {sjb.石头}");
                            break;
                        case 2:
                            Console.WriteLine($"{name} 出拳  {sjb.剪刀}");
                            break;
                        case 3:
                            Console.WriteLine($"{name} 出拳  {sjb.布}");
                            break;
                    }
                    if (a==1)
                    {
                        Console.WriteLine($"不错{playname} 你赢了");
                        platname1++;

                    }
                    else if (a==2)
                    {
                        Console.WriteLine($"笨蛋{playname} 你输了");
                        botname1++;
                    }
                    else
                    {
                        Console.WriteLine("平局");
                        pj++;
                    }
                }

               
                int sum = platname1 + botname1 + pj;
                cq = sum;
                Console.WriteLine("=============================================");
                Console.WriteLine($"{playname}  VS  {name}");
                Console.WriteLine($"对战次数 {cq}");
                Console.WriteLine("姓名   得分");
                Console.WriteLine($"{playname }  {platname1}");
                Console.WriteLine($"{name}   {botname1}");
                Console.WriteLine("结果");
                if (platname1>botname1)
                {
                    Console.WriteLine("你胜利了！！！");
                }
                else if (platname1<botname1)
                {
                    Console.WriteLine("你输入了！！");
                }
                else
                {
                    Console.WriteLine("平局");
                }
                towgame();
                //Console.WriteLine("是否继续下一轮《y/n》");
                //string game1 = Console.ReadLine();
                //if (game1.Equals("y"))
                //{
                //    gogame();
                //}
                //else if (game1.Equals("n"))
                //{
                //    Environment.Exit(0);
                //}
            }
        }
        public void towgame() 
        {
            Console.WriteLine("是否开始下一轮《y/n》");
            string game = Console.ReadLine();
            if (game.Equals("y"))
            {
                gogame();
            }
            else if (game.Equals("n"))
            {

            }
            else
            {
                towgame();
            }
        
        }
        
    }
}
